package com.xhwy.service.impl;

import com.xhwy.entity.UserType;
import com.xhwy.mapper.UserTypeMapper;
import com.xhwy.service.UserTypeService;
import com.xhwy.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserTypeServiceImpl implements UserTypeService {

    @Autowired
    private UserTypeMapper userTypeMapper;

    /**
     * 分页查询
     *
     * @param userType 筛选条件
     * @param pageUtil 分页对象
     * @return 查询结果
     */
    @Override
    public PageUtil<UserType> queryAllUserTypesByLimit(UserType userType, PageUtil<UserType> pageUtil) {
        List<UserType> userTypes = userTypeMapper.queryAllUserTypesByLimit(userType, pageUtil);
        int total = userTypeMapper.count(userType);
        pageUtil.setList(userTypes);
        pageUtil.setTotalRecords(total);
        return pageUtil;
    }
}
